package timing.ukulele.portal.util;

import timing.ukulele.share.MenuGradeEnum;
import timing.ukulele.share.RoleTypeEnum;
import timing.ukulele.share.UserLabelEnum;
import java.util.Arrays;
import java.util.List;

/**
 * 系统用户角色菜单工具类
 * @author admin
 */
public final class UkuleleRbacUtil {

    /**
     * 通过用户标签获取菜单级别
     * @return
     */
    public static List<Integer> getMenuGradeByUserLabel(String userLabel) {
        if(UserLabelEnum.OPERATOR.getLabel().equals(userLabel)) {
            return Arrays.asList(MenuGradeEnum.OPERATOR.getValue());
        }
         else if(UserLabelEnum.PLATFORM.getLabel().equals(userLabel)) {
            return Arrays.asList(MenuGradeEnum.PLATFORM.getValue());
        }
        else if(UserLabelEnum.OPERATOR.getLabel().equals(userLabel)) {
            return Arrays.asList(MenuGradeEnum.ORG.getValue(), MenuGradeEnum.BUSINESS.getValue());
        }
        else if(UserLabelEnum.USER.getLabel().equals(userLabel)) {
            return null;
        } else{
            return null;
        }
    }

    /**
     * 通过用户标签获取角色级别
     * @return
     */
    public static List<Integer> getRoleTypeByUserLabel(String userLabel) {
        if(UserLabelEnum.OPERATOR.getLabel().equals(userLabel)) {
            return Arrays.asList(RoleTypeEnum.OPERATOR.getValue());
        }
        else if(UserLabelEnum.PLATFORM.getLabel().equals(userLabel)) {
            return Arrays.asList(RoleTypeEnum.PLATFORM.getValue());
        }
        else if(UserLabelEnum.OPERATOR.getLabel().equals(userLabel)) {
            return Arrays.asList(RoleTypeEnum.ORG.getValue());
        }
        else if(UserLabelEnum.USER.getLabel().equals(userLabel)) {
            return null;
        } else{
            return null;
        }
    }

    /**
     * 根据角色级别获取菜单级别
     * @return
     */
    public static List<Integer> getMenuGradeByRoleType(Integer roleLevel) {
        if(RoleTypeEnum.OPERATOR.getValue().equals(roleLevel)) {
            return Arrays.asList(MenuGradeEnum.OPERATOR.getValue());
        }
        else if(RoleTypeEnum.PLATFORM.getValue().equals(roleLevel)) {
            return Arrays.asList(MenuGradeEnum.PLATFORM.getValue());
        }
        else if(RoleTypeEnum.ORG.getValue().equals(roleLevel)) {
            return Arrays.asList(MenuGradeEnum.ORG.getValue(), MenuGradeEnum.BUSINESS.getValue());
        }
        else{
            return null;
        }
    }

}
